<?php
namespace mvc\validator;

abstract class Validator
{
    public $message;
    public $attributeLabel;
    public $label;
    public $value;
    public $attribute;
    public $model;

    public function __construct($model, $attribute, $value)
    {
        if(!method_exists($model, 'labels')) {
            throw new \Exception("Model缺少label()方法");
        }
        $label = $model->labels();
        $this->attributeLabel = isset($label[$attribute]) ? $label[$attribute] : $attribute;
        $this->value = $value;
        $this->attribute = $attribute;
        $this->model = $model;
    }

    abstract public function validate();
}